﻿using Newtonsoft.Json;

namespace DbBackupAssist
{
    public class DbBackupConfiguration
    {
        [JsonRequired]
        public List<string> DatabaseNames { get; set; }

        [JsonRequired]
        public string BackupDirectory { get; set; }

        public string ShareFolderName { get; set; }

        public TimeSpan BackupTime { get; set; } = new TimeSpan(22, 0, 0);

        public int RetentionDays { get; set; } = 3;

        public SqlDbServer RemoteSqlServer { get; set; }

        public SqlDbServer LocalSqlServer { get; set; }

        public string LoginAccount { get; set; }

        public string LoginPassword { get; set; }

        public DbBackupConfiguration()
        {
            this.DatabaseNames = new List<string>();

            this.RemoteSqlServer = new SqlDbServer();
            this.LocalSqlServer = new SqlDbServer();
        }
    }

    public class SqlDbServer
    {
        public string SqlInstance {  get; set; }
        public string UserName { get; set; }
        public string Password { get; set; }

        public bool TrustServerCertificate { get; set; } = true;

        public override string ToString()
        {
            return $"Server={this.SqlInstance};Uid={this.UserName};Pwd={this.Password};Trust Server Certificate={this.TrustServerCertificate}"; 
        }
    }
}
